package stalker;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

import network.e2e.FrameReader;
import network.e2e.FrameWriter;
import network.link.FrameInputStream;
import network.link.FrameOutputStream;

import org.junit.Assert;
import org.junit.Test;

import stalker.user.User;

public class StalkerParserTest {

  @Test
  public void testAll() throws IOException {
    Stalker test = User.createUser("Irvan");
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    FrameWriter fw = new FrameWriter(new FrameOutputStream(os));
    
    StalkerParser.send(test, fw);
    
    FrameReader fr = new FrameReader(new FrameInputStream(new ByteArrayInputStream(os.toByteArray())));
    
    System.out.println(os.toString());
    
    Stalker stalk = StalkerParser.retrieve(fr);
    
    Assert.assertEquals(stalk, test);
    
    
  }

}
